<template>
	<Container >
		<view class="login-index">
			<image class="logo" src="/static/logo.png" mode=""></image>
			<view class="form">
				<view class="form-item">
					<image src="/static/user.svg" mode="heightFix"></image>
					<input v-model="params.username" type="text" placeholder="请输入登录账号" maxlength="11" />
				</view>
				<view class="form-item">
					<image src="/static/pwd.svg" mode="heightFix"></image>
					<input v-model="params.password" type="password" placeholder="请输入登录密码" maxlength="20"/>
				</view>
			</view>
			<view class="btn" @click="loginAction">登 录</view>
		</view>
	</Container>
</template>

<script>
	import {loginApi} from '@/http/user.js'
	export default {
		data() {
			return {
				params: {
					username: '',
					password: '',
				}
			};
		},
		methods: {
			async loginAction () {
				const {ok, data} = await loginApi(this.params)
				if(!ok) return
				console.log(data)
				uni.setStorageSync('Authorization', data.token)
				uni.setStorageSync('user__info', data.user)
				uni.switchTab({
					url: '/pages/index/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.login-index {
	min-height: 100vh;
	background-color: #151822;
	.logo {
		display: block;
		margin: auto;
		width: 600rpx;
		height: 600rpx;
		border-radius: 32rpx;
	}
	
	.form {
		padding: 0 64rpx;
		.form-item {
			display: flex;
			align-items: center;
			height: 100rpx;
			border-bottom: 2rpx solid #666;
			image {
				height: 40rpx;
				flex: none;
				margin-right: 10rpx;
			}
			input {
				height: 100rpx;
				color: #fff!important;
				::placeholder {
					color: #fff!important;
				}
			}
		}
	}
	.btn {
		color: #fff;
		width: 650rpx;
		height: 100rpx;
		background-color: #f9bc06;
		font-size: 36rpx;
		border-radius: 16rpx;
		margin: 80rpx auto 40rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		letter-spacing: 5rpx;
		font-weight: 600;
	}
}
</style>
